<template>
  <view>
    <button @tap="success">success</button>
    <button @tap="modal">modal</button>
    <button @tap="confirm">confirm</button>
    <button @tap="alert">alert</button>
    <button @tap="error">error</button>
    <button @tap="loading">loading</button>
    <button @tap="navLoading">navLoading</button>
    <button @tap="loaded">loaded</button>
    <button @tap="action">action</button>
    <button @tap="actionWithFunc">actionWithFunc</button>
  </view>
</template>

<script>
  import Tips from '../utils/tips';

  export default {
    methods: {
      success() {
        console.log('success');
        Tips.success('成功示例');
      },
      modal() {
        Tips.modal('模态视图示例');
      },
      confirm() {
        Tips.confirm(
          '确认视图示例',
          () => { console.log('this is callback'); },
          {name: 'lixxxxx'}
        ).then((d) => { console.log(d); })
          .catch((e) => { console.log(e); });
      },
      alert() {
        Tips.alert('alert示例', '/image');
      },
      error() {
        Tips.error('错误弹框示例', () => {
          console.log('onHide');
        });
      },
      loading() {
        Tips.loading();
      },
      navLoading() {
        Tips.navLoading();
      },
      loaded() {
        Tips.loaded();
      },
      action() {
        Tips.action('action', '示例', '代码');
      },
      actionWithFunc() {
        Tips.actionWithFunc(
          ['action', '示例', '代码'],
          '#A54445',
          () => { console.log('action'); },
          () => { console.log('示例'); },
          () => { console.log('代码'); }
        );
      }
    }
  };
</script>
